For the following figures, We only focus on reordered orders on Sunday.

Column

Chart A

Column

Chart B

Chart C

rmarkdown::render(“dashboard.Rmd”, output_format = “flexdashboard::flex_dashboard”)

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
```

For the following figures, We only focus on reordered orders on Sunday.

```{r}
data("instacart")

instacart = 
  instacart %>% 
  as_tibble(instacart) %>%
  filter(order_dow == 0, reordered == 1) %>%
  drop_na()
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart A


```{r}
instacart %>%
  count(aisle) %>%
  filter(n > 5000) %>%
  mutate(aisle = fct_reorder(aisle, n)) %>% 
  mutate(count = n) %>%
  plot_ly(x = ~aisle, y = ~count, type = "bar", color = ~aisle, alpha = 0.5, colors = "viridis"
  )
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
instacart %>%
  mutate(department = fct_reorder(department, order_hour_of_day)) %>% 
  filter(department %in% c("bakery", "canned goods", "meat seafood", "alcohol",
                           "beverages","diary eggs","deli","frozen", "snacks")) %>%
  plot_ly(
    y = ~ order_hour_of_day, color = ~department, type = "violin",
    colors = "viridis")
```


### Chart C

```{r}
instacart %>%
  filter(department == "alcohol") %>%
  plot_ly(x = ~aisle, y = ~order_hour_of_day, type = "scatter", mode = "markers",
          alpha = .5)
```

rmarkdown::render("dashboard.Rmd", output_format = "flexdashboard::flex_dashboard")